package test.my.com.myapplicationtest.horizontal_progress_view;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.RelativeLayout;
import android.widget.TextView;

import test.my.com.myapplicationtest.R;
import test.my.com.myapplicationtest.utils.LogUtil;

/**
 * Author : cooper
 * Time :  2018/3/20 下午3:14
 * Description :
 */

public class HorizontalProgressActivity extends Activity {

    private HorizontalProgressView horizontalProgressView;
    private TextView tv_date;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.aty_hrizontal_progress_view);
        horizontalProgressView = (HorizontalProgressView) findViewById(R.id.hp);
        horizontalProgressView.setProgress(0);


        tv_date = (TextView) findViewById(R.id.tv_date);

        final RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) horizontalProgressView.getLayoutParams();
        LogUtil.e("ah  layoutParams.leftMargin ==  "+layoutParams.leftMargin);
        final RelativeLayout.LayoutParams tvLp = (RelativeLayout.LayoutParams) tv_date.getLayoutParams();

//        tvLp.leftMargin = layoutParams.leftMargin + 100;

        horizontalProgressView.setPositionCallBack(new HorizontalProgressView.PositionCallBack() {
            @Override
            public void getPosition(float x, float y) {
                tvLp.leftMargin = layoutParams.leftMargin + (int)x -tv_date.getWidth()/2 ;
                tv_date.requestLayout();
                LogUtil.e("ah getPosition x ==  "+x);
                LogUtil.e("ah tv_date.getWidth()/2  ==  "+tv_date.getWidth()/2);
            }
        });



    }
}
